<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="umsroot.css">
<TITLE>
Port Profiler
</TITLE>
</HEAD>
<BODY >
<A HREF="umsroot089.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="umsroot083.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="umsroot091.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc212">15.7</A>&nbsp;&nbsp;Port Profiler</H2>
<A NAME="@default880"></A>
The port profiler is a performance analysis tool based on the idea of
counting of events during program execution. The events that are
counted are defined in terms of the 'box model' of execution (the same
model that the debugger uses, see chapter <A HREF="umsroot075.html#boxmodel">14.1</A>). In this
box model, predicates are entered though <EM>call</EM>, <EM>redo</EM> or <EM>resume</EM> ports,
and exited through <EM>exit</EM>, <EM>*exit</EM>, <EM>fail</EM> or <EM>leave</EM> ports. In addition, other
interesting events are indicated by ports as well (<EM>next</EM>, <EM>else</EM>, <EM>delay</EM>). <BR>
<BR>
The usage is as follows: 
<OL CLASS="enumerate" type=1><LI CLASS="li-enumerate">
Compile your program in debug mode, as you would normally do during program development.
<LI CLASS="li-enumerate">Load the port_profiler library 
<LI CLASS="li-enumerate">Run the query which you want to examine, using port_profile/2: 
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
?- port_profile(queen([1,2,3,4],Out), []).
</PRE></BLOCKQUOTE>
</OL>
This will print the results in a table like the following:
<PRE CLASS="verbatim">
PREDICATE       CALLER               call     exit     fail    *exit     redo
-           /3  nodiag      /3         46       46        .        .        .
=\=         /2  nodiag      /3         46       45        1        .        .
qperm       /2  qperm       /2         30       28        .       16       14
qdelete     /4  qperm       /2         20       18        .       12       10
nodiag      /3  nodiag      /3         17       14        3        .        .
nodiag      /3  safe        /1         17        7       10        .        .
+           /3  nodiag      /3         17       17        .        .        .
qdelete     /4  qdelete     /4         10        9        .        3        2
qperm       /2  queen       /2          1        .        .       11       10
safe        /1  queen       /2         11        1       10        .        .
safe        /1  safe        /1          7        4        3        .        .
queen       /2  trace_body  /2          1        .        .        1        .
</PRE>Each row of the table shows the information for a particular predicate
(by default split according to different caller predicates).
The table is sorted according to entry port count (<I>call</I>+<I>redo</I>+<I>resume</I>).
The port counts give information about
<UL CLASS="itemize"><LI CLASS="li-itemize">
what are the most frequently called predicates (call ports)
<LI CLASS="li-itemize">whether predicates failed unexpectedly (fail ports)
<LI CLASS="li-itemize">whether predicates exited nondeterministically (*exit ports), i.e.
 whether they left behind any choice-points for backtracking.
<LI CLASS="li-itemize">whether nondeterministically exited predicates were ever re-entered
 to find alternative solutions (redo ports).
<LI CLASS="li-itemize">whether predicates did internal backtracking (next ports) in order
 to find the right clause. This may indicate suboptimal indexing.
<LI CLASS="li-itemize">how often predicates were delayed and resumed.
</UL>
For more details about different options and output formats, see
the <A HREF="../bips/lib/port_profiler/index.html"><B>Reference Manual</B></A><A NAME="@default881"></A>.<BR>
<BR>
<HR>
<A HREF="umsroot089.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="umsroot083.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="umsroot091.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
